package edu.nf.ch03.service;

import edu.nf.ch03.entity.User;
import edu.nf.ch03.mapper.UserMapper;
import edu.nf.ch03.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author CSY
 * @date 2025 - 04 - 23
 */
public class UserService {
    public User getUserById(int id){
        return MybatisUtils.getSqlSession()
                .getMapper(UserMapper.class)
                .getUserById(id);
    }

    public List<User> listUsers(){
        return MybatisUtils.getSqlSession()
                .getMapper(UserMapper.class)
                .listUsers();
    }

    public Map<String, Object> getUserByName(String name){
        return MybatisUtils.getSqlSession()
                .getMapper(UserMapper.class)
                .getUserByName(name);
    }

    public List<Map<String, Object>> listUserMap(){
        return MybatisUtils.getSqlSession()
                .getMapper(UserMapper.class)
                .listUserMap();
    }
}
